package hbt;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import model.*;

public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
             config.addAnnotatedClass(Arbitro.class);
             config.addAnnotatedClass(Equipo.class);
             config.addAnnotatedClass(Estadistica.class);
             
             config.addAnnotatedClass(IdCategoriaPosicion.class);
             config.addAnnotatedClass(Categoria.class);
             config.addAnnotatedClass(Fecha.class);
             config.addAnnotatedClass(Fixture.class);
             config.addAnnotatedClass(Jugador.class);
             config.addAnnotatedClass(Partido.class);
             config.addAnnotatedClass(Planilla.class);
             config.addAnnotatedClass(Playoff.class);
             config.addAnnotatedClass(Posicion.class);
             config.addAnnotatedClass(Preferencia.class);
             config.addAnnotatedClass(Regular.class);
             config.addAnnotatedClass(Sede.class);
             config.addAnnotatedClass(Torneo.class);
             config.addAnnotatedClass(Turno.class);          
             
             sessionFactory = config.buildSessionFactory();
             
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
